package com.whcoding.designpatterns.pattern.factorypattern.easyfactory;

import com.whcoding.designpatterns.pattern.factorypattern.easyfactory.service.AudiCarImpl;
import com.whcoding.designpatterns.pattern.factorypattern.easyfactory.service.BydCarImpl;
import com.whcoding.designpatterns.pattern.factorypattern.easyfactory.service.ICar;
import com.whcoding.designpatterns.pattern.factorypattern.easyfactory.service.TeslaCarImpl;

/**
 * @program: spring-boot-learning
 * @description:
 * @author: whcoding
 * @create: 2022-09-19 16:38
 **/
public class CarFactory {
	//简单工厂方法一：
	public static ICar getCar(String carName) {
		if (carName.equals("奥迪")) {
			return new AudiCarImpl();
		} else if (carName.equals("特斯拉")) {
			return new TeslaCarImpl();
		} else if (carName.equals("BYD")) {
			return new BydCarImpl();
		} else {
			return null;
		}
	}

	//简单工厂方法二：
	public static ICar getAudiCar() {
		return new AudiCarImpl();
	}

	public static ICar getTeslaCar() {
		return new TeslaCarImpl();
	}

	public static ICar getBydCar() {
		return new BydCarImpl();
	}

}
